<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
// 			var arr=[2,8,5,0,5,2,6,7,2];
// 			function unique1(arr){
// 			  var arr2=[];
// 			  for (var i = 0; i < arr.length; i++) {
// 				 if(arr2.indexOf(arr[i])==-1){
// 				  arr2.push(arr[i]);
// 				 }
// 			  }
// 			  return arr2;
// 			}
// 			document.write(unique1(arr))
			// console.log(unique1(arr))
			
			var arr= [1,1,1,1,1,2,3,4,5,6,];
				arr2 = [];
				function a(arr) {
					for (i = 0; i < arr.length; i++) {
						if(arr2.indexOf(arr[i]) < 0) {
							arr2.push(arr[i]);
						}
					}
				return arr2;
			}
			document.write (a(arr) + '<br>');
			document.write (arr2.indexOf(arr[8]) + '<br>');
			
			var str="Hello world!"
			document.write(str.indexOf("Hello") + "<br />") //0
			document.write(str.indexOf("World") + "<br />") //-1
			document.write(str.indexOf("world")) //6
			
// 			var sum = 0;
// 				console.time("fora");
// 				for ( i = 0; i < arr.length; i++) {
// 					sum += arr[i];
// 				}
// 				console.timeEnd("fora");
// 				console.log(sum);

		
				var names = ['Alice', 'Bob', 'Tiff', 'Bruce', 'Alice'];
				 
				var countedNames = names.reduce(function (allNames, name) { 
				  if (name in allNames) {
					allNames[name]++;
				  }
				  else {
					allNames[name] = 1;
				  }
				  return allNames;
				}, {});
				// countedNames is:


		</script>
	</body>
</html>
